home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Resources / System / BoingBag1 / Contributions / Workbench / Prefs / T.H.E. / REXX / SortAppIcon.rexx < prev    next >
OS/2 REXX Batch file  |  1999-11-14  |  2KB  |  82 lines

  1. /*
  2.    $VER: SortAppIcon.rexx 1.0 (14.11.99) Copyright (c) Nils Görs.
  3.  
  4.    will sort APPICONS and TOOLS at the bottom of the Workbench window.
  5. */
  6.  
  7. spacex = 6
  8. spacey = 10
  9. startx = 10
  10.  
  11. options results
  12.  
  13. ADDRESS WORKBENCH
  14.  
  15.  
  16. GETATTR OBJECT WINDOWS.ACTIVE        /* Ist "root" das aktive Fenster? */
  17. IF result ~= "root" THEN EXIT        /* Nein, dann brechen wir an dieser Stelle ab! */
  18. activeWin = result
  19.  
  20. GETATTR OBJECT WINDOW.ICONS.ALL.COUNT NAME '"'||activeWin||'"'
  21. NumOfIcons = result
  22.  
  23. GETATTR OBJECT WINDOW.SCREEN.HEIGHT NAME '"'||activeWin||'"'
  24. winHeight = result
  25. GETATTR OBJECT WINDOW.SCREEN.WIDTH NAME '"'||activeWin||'"'
  26. winWidth = result
  27. GETATTR APPLICATION.FONT.SCREEN.HEIGHT
  28. FontHeight = result
  29.  
  30. maxiconheight = 0
  31. maxiconwidth = 0
  32. posx = 0
  33. numIcon = 0
  34. changes = 0
  35.  
  36. do i = 0 to numofIcons-1
  37.     GETATTR OBJECT WINDOW.ICONS.ALL.i NAME '"'||activeWin||'"' STEM IconInfo.i
  38.  
  39.     IF IconInfo.i.type = "APPICON" | IconInfo.i.type = "TOOL" THEN DO
  40.         IF posx > winWidth THEN DO
  41.             winheight = winheight - maxiconheight - fontHeight
  42.             posx = 0
  43.         numIcon = 0
  44.         END
  45.  
  46.         GETATTR APPLICATION.FONT.SCREEN.SIZE NAME '"'||IconInfo.i.name||'"'
  47.         namesize = result
  48.  
  49.         IF IconInfo.i.HEIGHT > maxiconheight THEN maxiconheight = IconInfo.i.HEIGHT
  50.         posy = winHeight-4 - IconInfo.i.height - fontHeight - fontHeight
  51.  
  52.         IF namesize > IconInfo.i.WIDTH THEN posx = namesize + posx + spacex
  53.                             ELSE posx = IconInfo.i.WIDTH + posx + spacex
  54.  
  55.         IF posx+IconInfo.i.WIDTH > winWidth THEN DO
  56.             posy = posy - maxiconheight - fontHeight
  57.             posx = 0
  58.             winheight = posy + maxiconheight + fontHeight + fontHeight
  59.         numIcon = 0
  60.         END
  61.  
  62.         IF numicon = 0 THEN posx = startx
  63.  
  64.         ICON WINDOW '"'||activeWin||'"' '"'||IconInfo.i.Name||'"' X posx Y posy
  65.         numIcon = 1
  66.         changes = 1
  67.     END
  68. END
  69. IF changes = 1 THEN DO
  70.     requesterdata='`requestchoice "SortAppIcon.rexx" "Save changes to disk?" "Yes|No"`'
  71.     IF ShellResult(requesterdata) = 1 THEN MENU WINDOW '"'||activeWin||'"' INVOKE WINDOW.SNAPSHOT.ALL
  72. END
  73. EXIT
  74.  
  75. ShellResult:
  76. PARSE ARG ShellCmd
  77. cmdid='req'pragma('id')
  78. address command 'rxset' cmdid Shellcmd
  79. from_Shell=getclip(cmdid)
  80. call setclip(cmdid,'')
  81. RETURN(from_Shell)
  82.